<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="layout" content="main" />
        <title><g:message code="user.show" default="SHOW USER" /></title>
    </head>
    <body>
        <div class="nav">
            <span class="menuButton"><a class="home" href="${createLinkTo(dir: '')}"><g:message code="home" default="HOME" /></a></span>
            <span class="menuButton"><g:link class="list" action="list"><g:message code="user.list" default="USER LIST" /></g:link></span>
            <span class="menuButton"><g:link class="create" action="create"><g:message code="user.new" default="NEW USER" /></g:link></span>
        </div>
        <div class="body">
            <h1><g:message code="user.show" default="SHOW USER" /></h1>
            <g:if test="${flash.message}">
            	<div class="message"><g:message code="${flash.message}" args="${flash.args}" default="${flash.defaultMessage}" /></div>
            </g:if>
            <g:form>
                <g:hiddenField name="id" value="${userInstance?.id}" />
                <div class="dialog">
                    <table>
                        <tbody>
                            <tr class="prop">
                                <td valign="top" class="name"><g:message code="user.alias" default="ALIAS" />:</td>
                                <td valign="top" class="value">${fieldValue(bean: userInstance, field: "alias")}</td>
                                <td rowspan="8">
                                	<img class="detail" width="600px" height="400px" 
                                		src="${resource(dir:userInstance.pathFile,file:userInstance.nameFile +'.'+ userInstance.extFile)}" title="IMAGE" alt="IMAGE"/>
	                            </td>
                            </tr>
                            
                            <tr class="prop">
                                <td valign="top" class="name"><g:message code="user.name" default="NAME" />:</td>
                                <td valign="top" class="value">${fieldValue(bean: userInstance, field: "name")}</td>
                            </tr>
                            
                            <tr class="prop">
                                <td valign="top" class="name"><g:message code="user.lastName" default="LAST NAME" />:</td>
                                <td valign="top" class="value">${fieldValue(bean: userInstance, field: "lastName")}</td>
                            </tr>
                            
                            <tr class="prop">
                                <td valign="top" class="name"><g:message code="user.email" default="EMAIL" />:</td>
                                <td valign="top" class="value">${fieldValue(bean: userInstance, field: "email")}</td>
                            </tr>

							<tr class="prop">
                                <td valign="top" class="name"><g:message code="gender" default="GENDER" />:</td>
                                <td valign="top" class="value"><g:message code="gender.${userInstance?.gender}" default="GENDER" /></td>
                            </tr>
                            
							<tr class="prop">
                                <td valign="top" class="name"><g:message code="user.birdDay" default="BIRD DAY" />:</td>
                                <td valign="top" class="value"><g:formatDate date="${userInstance?.birdDay}" format="dd-MM-yyyy"/></td>
                            </tr>
                                                        
                            <tr class="prop">
                                <td valign="top" class="name"><g:message code="user.country" default="COUNTRY" />:</td>
                                <td valign="top" class="value">${fieldValue(bean: userInstance, field: "country")}</td>
                            </tr>
                            
                            <tr class="prop">
                                <td valign="top" class="name"><g:message code="user.favoritesComics" default="FAVORITES COMICS" />:</td>
                                <td  valign="top" style="text-align: left;" class="value">
                                    <ul>
	                                    <g:each in="${userInstance?.favoritesComics}" var="comicInstance">
	                                        <li><g:link controller="comic" action="show" id="${comicInstance.id}">${comicInstance.name}</g:link></li>
	                                    </g:each>
                                    </ul>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
                <div class="buttons">
                	<!-- ES EL USUARIO QUE LO HA CREADO -->
	                <g:if test="${session.user != null && session.user.alias == fieldValue(bean: userInstance, field: 'alias')}">
	                    <span class="button"><g:actionSubmit class="edit" action="edit" value="${message(code: 'edit', 'default': 'Edit')}" /></span>
                    	<span class="button"><g:actionSubmit class="delete" action="delete" value="${message(code: 'delete', 'default': 'Delete')}" onclick="return confirm('${message(code: 'delete.confirm', 'default': 'Are you sure?')}');" /></span>
                   </g:if>
                   
                   <!-- ES EL USUARIO QUE LO HA CREADO O EL ADMINISTRADOR -->
                   <g:if test="${(session.user != null && session.user.alias == fieldValue(bean: userInstance, field: 'alias')) || (session.user != null && session.user.admin == true)}">
                   		<g:if test="${fieldValue(bean: userInstance, field: 'disabled') == 'false'}">
                   			<span class="button"><g:actionSubmit class="disable" action="disable" value="${message(code: 'disable', 'default': 'DISABLE')}" /></span>
                   		</g:if>
                   		<g:else>
							<span class="button"><g:actionSubmit class="enable" action="enable" value="${message(code: 'enable', 'default': 'ENABLE')}" /></span>                   		
                   		</g:else>
                   </g:if>
                </div>
            </g:form>
        </div>
    </body>
</html>
